import { append, first } from 'mvdom';
import { render } from 'ts/render';
import { getValidLeftIncome } from 'ts/service-unit';
import { addDomEvents, BaseView } from '../base';



export class StatsIncomeView extends BaseView {

	//#region    ---------- View Events ---------- 
	events = addDomEvents(this.events, {
	});
	//#endregion ---------- /View Events ----------

	async postDisplay() {
		this.refresh();
	}

	private async refresh() {
		const result = await getValidLeftIncome();
		const tableFrag = render("StatsIncomeView-income-table", { items: result.unitSnapshots, total: result.totalIncome });
		append(first(this.el, ".section-results")!, tableFrag, "empty");
	}

}

